package com.aaa.controller;


import com.aaa.entity.Praise;
import com.aaa.service.impl.PraiseServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.awt.*;
import java.util.HashMap;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author Bean
 * @since 2021-09-05
 */
@RestController
@Api(tags = "视频赞")
@CrossOrigin
@RequestMapping("/praise")
public class PraiseController {

    @Autowired
    PraiseServiceImpl praiseService;

    @ApiOperation("增加赞")
    @RequestMapping(value = "add",method = RequestMethod.POST)
    public boolean add(@ApiParam("作品主键") Integer vid,@ApiParam("作者主键")Integer id,@ApiParam("赞的用户id") Integer uid,@ApiParam("赞用户昵称") String uname){
       return praiseService.add(vid,id,uid,uname);
    }
    @ApiOperation("取消赞")
    @RequestMapping(value = "dele",method = RequestMethod.POST)
    public boolean dele(@ApiParam("作品主键") Integer vid,@ApiParam("赞的用户id") Integer uid){
        HashMap<String, Object> objectObjectHashMap = new HashMap<>();
        objectObjectHashMap.put("v_id",vid);
        objectObjectHashMap.put("u_id",uid);
        return praiseService.removeByMap(objectObjectHashMap);
    }
}
